/***************************************************************************
 *            light.c
 *
 *  Fri Oct 10 02:34:36 2008
 *  Copyright  2008  Tiago Falcao
 *  <developer@tiagofalcao.com>
 ****************************************************************************/

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */
 
#include "light.h"

GLfloat light0[4]={0., 10000000., 10000000., 1.}; // posicao da luz
GLfloat light1[4]={100., 0., 0., 1.}; // posicao da luz
GLfloat light2[4]={-100., 0., 0., 1.}; // posicao da luz


void light_init(){
	GLfloat luz10[4]={1.,1.,1.,1.};
	GLfloat luz1[4]={.1,.1,.1,1.};
	GLfloat luz9[4]={.9, .9, .9, 1.};
	GLfloat luz8[4]={.8,.8,.8,1.};
	GLfloat luz3[4]={.3,.3,.3,.5};
	 
	 // Ativa o uso da luz ambiente 
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, luz1);

	// Define os parâmetros da luz de número 0
	glLightfv(GL_LIGHT0, GL_AMBIENT, luz1);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, luz8 );
	glLightfv(GL_LIGHT0, GL_SPECULAR, luz3 );
	glLightfv(GL_LIGHT0, GL_POSITION, light0 );
	 
	// Define os parâmetros da luz de número 1
	//glLightfv(GL_LIGHT1, GL_AMBIENT, luz1);
	//glLightfv(GL_LIGHT1, GL_DIFFUSE, luz3 );
	//glLightfv(GL_LIGHT1, GL_SPECULAR, luz1 );
	//glLightfv(GL_LIGHT1, GL_POSITION, light1 );
	 
	// Define os parâmetros da luz de número 2
	//glLightfv(GL_LIGHT2, GL_AMBIENT, luz1);
	//glLightfv(GL_LIGHT2, GL_DIFFUSE, luz3 );
	//glLightfv(GL_LIGHT2, GL_SPECULAR, luz1 );
	//glLightfv(GL_LIGHT2, GL_POSITION, light2 );
	 
	 
 }

void light_setup(){
	glLightfv(GL_LIGHT0, GL_POSITION, light0 );
	//glLightfv(GL_LIGHT1, GL_POSITION, light1 );
	//glLightfv(GL_LIGHT2, GL_POSITION, light2 );
	//Habilita o uso de iluminação
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	//glEnable(GL_LIGHT1);
	//glEnable(GL_LIGHT2);
	
}
